﻿// Decompiled with JetBrains decompiler
// Type: Netick.Packet
// Assembly: Netick, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 6726ECA1-C773-4CF7-8952-E81B30D93B52
// Assembly location: D:\WorkSpaceDemo\UPM\NetickForUnity\Netick\Runtime\Netick.dll
// XML documentation location: D:\WorkSpaceDemo\UPM\NetickForUnity\Netick\Runtime\Netick.xml

using System.Runtime.CompilerServices;

#nullable disable
namespace Netick;

internal class Packet
{
  public ObjectRecord WorldRecord;
  public NativeArray<ObjectRecord> Entities;
  public int Count;

  [MethodImpl(MethodImplOptions.AggressiveInlining)]
  public void AddEntity(ObjectRecord record)
  {
    if (this.Count >= this.Entities.Length)
      this.Entities.ExpandCapacity((IAllocator) DirectAllocator.Instance);
    this.Entities.UnsafeSet(this.Count, record);
    ++this.Count;
  }

  public void Clear()
  {
    this.WorldRecord = new ObjectRecord();
    this.Count = 0;
  }

  public void Allocate(int capacity)
  {
    this.Entities = new NativeArray<ObjectRecord>();
    this.Entities.Allocate((IAllocator) DirectAllocator.Instance, capacity);
  }

  public void Deallocate() => this.Entities.Deallocate((IAllocator) DirectAllocator.Instance);
}
